﻿#ifndef __AVOID_CONTROL_INTERFACE_ROUND_HEAD_FILE_INCLUDED__
#define __AVOID_CONTROL_INTERFACE_ROUND_HEAD_FILE_INCLUDED__
#include "../control.h"

namespace swui
{
	// overload null
	enum class ctlRoundDirection : unsigned {
		leftTop = 1, 
		rightTop = 2, 
		rightBottom = 4, 
		leftBottom = 8, 
		all = 15
	};
	/* 
	 * 圆角矩形接口
	 * 为控件提供圆角矩形的样式
	 */
	class IRound : virtual public ctlRoot
	{
	public:
		IRound() : _round_enable(false), 
			_round_dir(ctlRoundDirection::all), 
			_round_radius(7) {}
	public:
		void enableRound(bool = true);
		bool isRoundEnabled();
	public:
		//设置圆角可用的方向
		void setRoundDirection(ctlRoundDirection dir);
		ctlRoundDirection getRoundDirection();
	public:
		//设置圆角半径
		void setRoundRadius(unsigned radius);
		unsigned getRoundRadius();
	protected:
		virtual bool _judge_point_(ctlPoint pt);
	private:
		bool _round_enable;
		ctlRoundDirection _round_dir;
		unsigned _round_radius;
	};

	inline void IRound::enableRound(bool b) {
		_round_enable = b;
		redraw();
	}
	inline bool IRound::isRoundEnabled() {
		return _round_enable;
	}
	inline void IRound::setRoundDirection(ctlRoundDirection dir) {
		_round_dir = dir;
		redraw();
	}
	inline ctlRoundDirection IRound::getRoundDirection() {
		return _round_dir;
	}
	inline void IRound::setRoundRadius(unsigned radius) {
		_round_radius = radius;
		redraw();
	}
	inline unsigned IRound::getRoundRadius() {
		return _round_radius;
	}
}

#endif